package com.teacher.util;

import java.util.Collection;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.common.model.Project;
import com.common.model.TeacherUser;
import com.teacher.service.TeacherService;

/**
 * 工具类 将Excel文件中的数据导入到数据库中
 * 
 * @author XHFSJ
 * 
 */
public class ExcelToDB {

	@Autowired
	private static TeacherService tservice;



	/**
	 * 将某集合中的所有Project元素遍历写入数据库中
	 * 
	 * @param projects
	 *            数据集合，要写入数据库中的集合
	 * @return
	 */
	public static boolean WriteIntoDB(Collection<Project> projects,
			HttpServletRequest request) {
		for (Project project : projects) {
			project.setTea_id(((TeacherUser) request.getSession().getAttribute(
					"user")).getId());
			tservice.AddProject(project);
		}
		return true;
	}
}
